package v2.chapter2.textFile;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class fileReadTest {

	public static void main(String[] args) throws IOException {
		String path = "F:/logs/";
		File file = new File(path);
		if (!file.isDirectory()) {
			System.out.println("文件：" + file.getName());
			System.out.println("path=" + file.getPath());
			System.out.println("absolutepath=" + file.getAbsolutePath());
			System.out.println("name=" + file.getName());
		} else {
			System.out.println("文件夹：" + file.getName());
			String[] filelist = file.list();
			for (int i = 0; i < filelist.length; i++) {
				File file2 = new File(path + filelist[i]);
				if (!file2.isDirectory()) {
					System.out.println("文件：" + file2.getName());
					System.out.println("path=" + file2.getPath());
					System.out.println("absolutepath=" + file2.getAbsolutePath());
					System.out.println("name=" + file2.getName());
					try (BufferedReader br = new BufferedReader(new FileReader(file2.getPath()))) {
						String line = null;
						while ((line = br.readLine()) != null) {
							System.out.println(line);
						}

					}
				}
			}
		}
	}
}
